
#ifndef LOG_COMMON_HPP
#define LOG_COMMON_HPP
#include <string>
#include <map>
namespace tulun
{
    static const size_t SMALL_BUFF_SIZE = 128;
    static const size_t MID_BUFF_SIZE = 256;
    enum class LOG_LEVEL
    {
        TRACE = 0,
        DEBUG,
        INFO,
        WARN,
        ERROR,
        FATAL,
        SYSERR,
        SYSFATAL,
        NUM_LOG_LEVELS
    };
    static const std::string IndexToStr[] =
        {
            "TRACE",         // 0
            "DEBUG",         // 1
            "INFO",          // 2
            "WARN",          // 3
            "ERROR",         // 4
            "FATAL",         // 5
            "SYSERR",        // 6
            "SYSFATAL",      // 7
            "NUM_LOG_LEVELS" // 8
    };
    static const char *IndToStr[] =
        {
            "TRACE",         // 0
            "DEBUG",         // 1
            "INFO",          // 2
            "WARN",          // 3
            "ERROR",         // 4
            "FATAL",         // 5
            "SYSERR",        // 6
            "SYSFATAL",      // 7
            "NUM_LOG_LEVELS" // 8
    };
    static const std::map<LOG_LEVEL, std::string> ImapStr =
        {
            {LOG_LEVEL::TRACE, "TRACE"},                  // 0
            {LOG_LEVEL::DEBUG, "DEBUG"},                  // 1
            {LOG_LEVEL::INFO, "INFO"},                    // 2
            {LOG_LEVEL::WARN, "WARN"},                    // 3
            {LOG_LEVEL::ERROR, "ERROR"},                  // 4
            {LOG_LEVEL::FATAL, "FATAL"},                  // 5
            {LOG_LEVEL::SYSERR, "SYSERR"},                // 6
            {LOG_LEVEL::SYSFATAL, "SYSFATAL"},            // 7
            {LOG_LEVEL::NUM_LOG_LEVELS, "NUM_LOG_LEVELS"} // 8
    };
    static const std::string GetIndexToStr(LOG_LEVEL &le)
    {
        std::string str = "not LEVEL";
        switch (le)
        {
        case LOG_LEVEL::TRACE:
            str = "TRACE";
            break;
        case LOG_LEVEL::DEBUG:
            str = "DEBUG";
            break;
        case LOG_LEVEL::INFO:
            str = "INFO";
            break;
        case LOG_LEVEL::WARN:
            str = "WARN";
            break;
        case LOG_LEVEL::ERROR:
            str = "ERROR";
            break;
        case LOG_LEVEL::FATAL:
            str = "FATAL";
            break;
        case LOG_LEVEL::SYSERR:
            str = "SYSERR";
            break;
        case LOG_LEVEL::SYSFATAL:
            str = "SYSFATAL";
            break;
        case LOG_LEVEL::NUM_LOG_LEVELS:
            str = "NUM_LOG_LEVELS";
            break;
        default:
            break;
        }
        return str;
    }
} // namespace tulun
#endif